<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">

    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css"/>
    <style>
        .form-horizontal .form-label {
            cursor: text;
            margin-left: -37px;
            line-height: 14px;
            cursor: pointer;
        }

        .form-horizontal .form-label_1 {
            margin-left: 0;
        }
    </style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 开发者账号审核 <span
        class="c-gray en">&gt;</span>个人开发者 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"
                                              id="refresh"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>

<div class="page-container">
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="300">ID</th>
                <th width="100">身份证名称</th>
                <th width="200">身份证号码</th>
                <th>图片</th>
                <th width="150">申请时间</th>
                <th width="150">邮箱</th>
                <th width="50">状态</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="data" items="${dataMap}">
                <tr class="text-c">
                    <td>${data[0]}</td>
                    <td>${data[1]}</td>
                    <td>${data[2]}</td>
                    <td><a target="_blank"
                           href="/DeveloperApplyAction/admin/lookIconAction?id=${data[0]}"><img
                            width="100"
                            class="picture-thumb"
                            src="/DeveloperApplyAction/admin/lookIconAction?id=${data[0]}" alt="图片出错">
                    </a></td>
                    <td><fmt:formatDate value="${data[3]}" pattern="yyyy-MM-dd HH:mm"/></td>
                    <td>${data[4]}</td>
                    <td><c:choose>
                        <c:when test="${data[5]==1}">
                            已通过
                        </c:when>
                        <c:when test="${data[5]==-1}">
                            未通过
                        </c:when>
                        <c:otherwise>
                            待审核
                        </c:otherwise>
                    </c:choose></td>
                    <td><a style="text-decoration:none" href="javascript:;" title="通过"
                           onclick="passApply(this,'${data[0]}')"><i
                            class="Hui-iconfont">&#xe6e1;</i></a>
                        <a title="拒绝" href="javascript:;" class="ml-5" style="text-decoration:none"
                           onclick="modaldemo('${data[0]}','${data[4]}')"><i
                                class="Hui-iconfont">&#xe6e4;</i></a><a title="查看详情" href="javascript:;" class="ml-5"
                                                                        style="text-decoration:none"><i
                                class="Hui-iconfont">&#xe6df;</i></a></td>


                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<!--弹窗拒绝原因-->
<div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content radius">
            <div class="modal-header">
                <h3 class="modal-title">请选择拒绝原因</h3>
                <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:;">×</a>
            </div>
            <div class="modal-body">
                <form class="form form-horizontal">
                    <div class="row cl">
                        <div class="formControls col-xs-1 col-sm-1">
                            <input name="contents" type="checkbox" id="contents1" value="实名认证未通过">
                        </div>
                        <label class="form-label col-xs-3 col-sm-3" for="contents1">实名认证未通过</label>

                        <div class="formControls col-xs-1 col-sm-1">
                            <input name="contents" type="checkbox" id="contents2" value="联系方式不正确">
                        </div>
                        <label class="form-label col-xs-3 col-sm-3" for="contents2">联系方式不正确</label>

                        <div class="formControls col-xs-1 col-sm-1">
                            <input name="contents" type="checkbox" id="contents3" value="其他">
                        </div>
                        <label class="form-label col-xs-3 col-sm-3" style=" text-align: left;margin-left: -18px;"
                               for="contents3">其他</label>

                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-5 col-sm-3 form-label_1"><span
                                class="c-red">*</span>未通过原因描述：</label>
                        <div class="formControls col-xs-7 col-sm-8">
                            <textarea class="textarea" name="contents" required id="content"
                                      placeholder="详细原因"></textarea>

                        </div>

                    </div>
                </form>
            </div>
            <span hidden id="value"></span>
            <span hidden id="email"></span>
            <div class="modal-footer">
                <button class="btn btn-primary" onclick="refuseApply(this)">确定</button>
                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--[if lt IE 9]>
<script type="text/javascript" src="/admin/lib/html5shiv.js"></script>
<script type="text/javascript" src="/admin/lib/respond.min.js"></script>
<![endif]-->
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
<script>
    $(function () {
        $('.table-sort').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": []
        });

    });

    function passApply(obj, id) {
        layer.confirm('确认通过申请么？', function (index) {
            $.ajax({
                type: 'GET',
                url: '/DeveloperApplyAction/admin/passApply?type=3&id=' + id,
                dataType: 'json',
                success: function (data) {
                    location.replace(location.href);
                    layer.msg('已通过,已自动刷新', {icon: 1, time: 1000});
                },
                error: function (data) {
                    console.log(data.msg);
                },
            });


        });

    }

    function modaldemo(value, email) {
        $("#modal-demo").modal("show");

        $("#value").text(value);
        $("#email").text(email);

    }


    function refuseApply(obj) {
        var id = $("#value").text();
        var email = $("#email").text();
        var value = ""
        var temp = 0
        $(".modal-body input[name='contents']:checked").each(function (index, elem) {
            console.log(index);
            value += index + 1 + ":" + $(elem).val() + ",";
            temp = index + 2;
        });
        value += temp + ":" + $("#content").val();
        $.post("/DeveloperApplyAction/admin/refuseApply", {
            id: id,
            content: value,
            email: email
        }, function (data) {
            if (data.valueOf() == "true") {
                location.replace(location.href);
            } else {
                layer.msg('拒绝失败，请刷新后重试', {icon: 1, time: 1000});
            }

        });
    }
</script>
</body>
</html>